<!-- 用户登录界面 -->
<template>
  <div class="user-login">
    <div class="login-content">
      <img
        src="https://api.java.crmeb.net/crmebimage/public/operation/2021/09/23/e50ee2515544455a826990701abdaf90jhr0s3jzfp.png"
        alt=""
      />
    </div>
    <div class="user-input">
      <van-cell-group>
        <van-field
          clearable
          left-icon="phone-circle-o"
          placeholder="输入手机号"
          size="large"
          v-model="account"
        />
        <van-field
          center
          clearable
          placeholder="请输入短信验证码"
          left-icon="lock"
          v-model="password"
          type="password"
        >
          <template #button>
            <van-button size="small" type="primary">获取验证码</van-button>
          </template>
        </van-field>
      </van-cell-group>
    </div>
    <div class="login-btn">
      <van-button type="primary" to="" block color="#ff448f" @click="userlogin"
        >登录</van-button
      >
    </div>
    <div class="check">账号登录</div>
  </div>
</template>

<script>
export default {
  name: "LoginPage",

  data() {
    return {
      userLogin: [],
      phone: "",
      password: "",
      account: "",
    };
  },

  methods: {
    async userlogin() {
      if (this.account != "15660585765" || this.password != "wxr123456") {
        alert("账号或密码错误");
        return;
      }
      await this.$requestTools(
        "https://apif.java.crmeb.net/api/front/login",
        "POST",
        {
          account: this.account, //账户，手机号
          password: this.password, //密码
        }
      ).then((data) => {
        const token = data.data.data.token;
        sessionStorage.setItem("token", token);
        const beforeUrl = this.$store.state.beforeUrl;
        this.$router.push(beforeUrl);
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.user-login {
  padding: 15px;
  background-color: #eee;
  height: 100vh;
  // 头像
  .login-content {
    img {
      width: 90px;
      height: 90px;
      margin: 0 auto;
      display: block;
      margin-top: 100px;
    }
  }
  // 输入框
  .user-input {
    margin-top: 50px;
    ::v-deep .van-cell {
      &:nth-child(1) {
        border-radius: 5px 5px 0px 0px;
        padding: 10px;
      }
      &:nth-child(2) {
        border-radius: 0px 0 5px 5px;
        border-top: 1px solid #eee;
        padding: 10px;
        margin-bottom: 40px;
      }
    }
    ::v-deep .van-button {
      border: none;
      background-color: white;
      color: #ff448f;
      font-size: 13px;
    }
  }
  .login-btn {
    &::v-deep .van-button {
      border-radius: 25px;
    }
  }
  .check {
    text-align: center;
    color: #999;
    font-size: 14px;
    margin: 15px;
  }
}
</style>
